class CreateRoles < ActiveRecord::Migration
  def self.up
    create_table :roles do |t|
      t.integer :company_id    ,:null => false  #所属公司的ID
      t.string  :name          ,:null => false  ,:limit => 50    #名称
      t.integer :employee_id   ,:null => false  #添加，编辑者
      t.string  :description                    #写一些备注之类的信息      
      t.string  :financial_management           ,:limit => 10 ,:default => '否' #是否有财务处理权，即有无显示金钱数额的权限
      t.string  :check_cost_price               ,:limit => 10 ,:default => '否'
      t.string  :cross_dept_sale_order_query    ,:limit => 10 ,:default => '否' #跨部门销售订单查询
      t.string  :unsafe_discount_audit          ,:limit => 10 ,:default => '否' #非安全折扣审批
      t.decimal :discount      ,:precision => 5 ,:scale => 3  ,:default => 1   #最低折扣
      t.integer :is_locked     ,:limit => 1 ,:default => 1 #锁定 1为True 0为False
      t.integer :lock_version  ,:default => 0  #乐观锁
      t.timestamps
    end
    
  end

  def self.down
    drop_table :roles
  end
end
